//--------------------------------------
// silk-editor-plugin Project
//
// SilkNodeRule.java
// Since: 2010/11/12
//
// $URL$ 
// $Author$
//--------------------------------------
package org.xerial.silk.editor.plugin.text;

import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IToken;

public class SilkNodeRule extends EndOfLineRule
{

    public SilkNodeRule(IToken token) {
        super("-", token);
    }

    @Override
    protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
        int c = scanner.read();
        if (c == '-') {
            c = scanner.read();
            if ('0' <= c && c <= '9') {
                // negative number is detected - abort
                scanner.unread();
                scanner.unread();
                return false;
            }
        }
        boolean flag = super.sequenceDetected(scanner, sequence, eofAllowed);
        return flag;

    }

}
